package com.yh.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yh.bean.CarApply;
import com.yh.bean.CarManage;
import com.yh.dao.CarDao;

@Service
public class CarServiceImpl implements CarService {
	
	@Autowired
	private CarDao cd;
	
	//新增车辆
	@Override
	public int addcar(CarManage cm) {
		// TODO Auto-generated method stub
		int i=cd.addcar(cm);
		return i;
	}

	//查询车辆
	@Override
	public List<CarManage> querycar() {
		// TODO Auto-generated method stub
		List<CarManage> cmlist=cd.querycar();
		return cmlist;
	}
	
	//修改车辆
	@Override
	public int updatecar(CarManage cm) {
		// TODO Auto-generated method stub
		int i=cd.updatecar(cm);
		return i;
	}
	
	//删除车辆
	@Override
	public int delcar(int cm_id) {
		// TODO Auto-generated method stub
		int i=cd.delcar(cm_id);
		return i;
	}
	
	//查看车辆状态
	@Override
	public Map checkcar(CarApply ca) {
		// TODO Auto-generated method stub
		String ca_carstatus1=cd.checkcar1(ca);//查询该车的出车时间是否与申请时间冲突
		String ca_carstatus2=cd.checkcar2(ca);//查询该车是否处于维修状态
		Map map=new HashMap();
		map.put("ck1", ca_carstatus1);
		map.put("ck2", ca_carstatus2);
		return map;
	}
	
	//申请用车
	@Override
	public int carapply(CarApply ca) {
		// TODO Auto-generated method stub
		int i=cd.carapply(ca);
		return i;
	}
	
	//查询车辆申请状态
	@Override
	public List<CarApply> querycarapply(CarApply ca) {
		// TODO Auto-generated method stub
		List<CarApply> querycarapplylist=cd.querycarapply(ca);
		return querycarapplylist;
	}
	
	//审批车辆
	@Override
	public int updatecarapply(CarApply ca) {
		// TODO Auto-generated method stub
		int i=cd.updatecarapply(ca);
		return i;
	}
	
	//删除申请
	@Override
	public int delcarapply(int ca_id) {
		// TODO Auto-generated method stub
		int i=cd.delcarapply(ca_id);
		return i;
	}

}
